//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)

using NUnit.Framework;
using SoapTrace.Core.Formatters;
using System;

namespace SoapTrace.Tests.RichTextBoxFormatting
{
	/// <summary>
	/// Tests the formatting of a Http Header in a rich text box.
	/// </summary>
	[ TestFixture ]
	public class HttpHeaderTestFixture : RichTextBoxFormatterTestFixtureBase
	{
		string Text = "POST /webservices/latest.asmx HTTP/1.1\r\n" +
			"User-Agent: Mozilla/4.0\r\n" +
			"Content-Type: text/xml\r\n" +
			"\r\n";
		
		HttpHeaderFormatter m_Formatter;
		
		/// <summary>
		/// Initialises each test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{
			base.CreateTextBox( );
			
			m_Formatter = new HttpHeaderFormatter( );
			
			FormattedText FormattedText = m_Formatter.Format( Text );
			
			RichTextBoxFormatter.Format( RichTextBox, FormattedText );
		}
		
		/// <summary>
		/// Check the first field name's colour.
		/// </summary>
		[ Test ]
		public void FirstFieldNameColour( )
		{
			Assert.AreEqual( m_Formatter.FieldNameColour, GetTextColour( "User-Agent", 39 ),
			                "First field name text colour is wrong." );
		}
		
		/// <summary>
		/// Check the first field delimiter's colour.
		/// </summary>
		[ Test ]
		public void FirstFieldDelimiterColour( )
		{
			Assert.AreEqual( m_Formatter.FieldDelimiterColour, GetTextColour( ":", 49 ),
			                "First field delimiter text colour is wrong." );
		}	
		
		/// <summary>
		/// Check the first field value's colour.
		/// </summary>
		[ Test ]
		public void FirstFieldValueColour( )
		{
			Assert.AreEqual( m_Formatter.FieldValueColour, GetTextColour( " Mozilla/4.0", 50 ),
			                "First field value text colour is wrong." );
		}		
		
		/// <summary>
		/// Check the second field name's colour.
		/// </summary>
		[ Test ]
		public void SecondFieldNameColour( )
		{
			Assert.AreEqual( m_Formatter.FieldNameColour, GetTextColour( "Content-Type", 63 ),
			                "Second field name text colour is wrong." );
		}	
		
		/// <summary>
		/// Check the second field delimiter's colour.
		/// </summary>
		[ Test ]
		public void SecondFieldDelimiterColour( )
		{
			Assert.AreEqual( m_Formatter.FieldDelimiterColour, GetTextColour( ":", 75 ),
			                "Second field delimiter text colour is wrong." );
		}	
		
		/// <summary>
		/// Check the second field value's colour.
		/// </summary>
		[ Test ]
		public void SecondFieldValueColour( )
		{
			Assert.AreEqual( m_Formatter.FieldValueColour, GetTextColour( " text/xml", 76 ),
			                "Second field value text colour is wrong." );
		}			
	}
}
